package com.zhuiyun.project.api.complaint.mapper;

import com.zhuiyun.project.api.complaint.entity.Complain;
import com.zhuiyun.project.api.complaint.entity.ComplaintAndUser;
import com.zhuiyun.project.common.mapper.BaseMapper;
import com.zhuiyun.project.common.response.CommonResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName ComplaintMapper
 * @Description TODO
 * @Author DF
 * @Date 2023/12/13 14:46
 **/
@Mapper
public interface ComplaintMapper extends BaseMapper<Complain> {
    @Select("<script>" +
            "select u.user_name,c.* from front_user u,complain c where u.id = c.user_id and c.del_flag = 0" +
            "<if test=\" complain.userId != null\">" +
            "and c.user_id = #{complain.userId}" +
            "</if>" +
            "<if test=\" complain.id != null\">" +
            "and c.id = #{complain.id}" +
            "</if>" +
            "</script>")
    List<ComplaintAndUser> selectall(@Param("complain") Complain complain);

    @Select("<script>" +
            "select u.user_name,c.id,c.user_id,c.complaint_content,c.complaint_time,c.del_flag,c.read_flag" +
            " from front_user u,complain c where u.id = c.user_id and c.del_flag = 0" +
            "<if test=\" complain.id != null\">" +
            "and c.id = #{complain.id}" +
            "</if>" +
            "</script>")
    ComplaintAndUser selectne(@Param("complain") Complain complain);
}
